<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class AuthRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * 验证规则
     *
     * @return array
     */
    public function rules()
    {

        if( Request::url() == url('auth/login') ){
            $data = [
                'email' => 'required|email|max:255',
                'password' => 'required|min:6',
            ];
        }else{
            $data = [
                'email' => 'required|email|max:255|unique:users',
                'password' => 'required|confirmed|min:6',
                'name' => 'required|min:2|max:255|unique:users,name',
            ];
        }

        return $data;


    }
}
